#ifndef	_CEXCEPTION_H_
#define	_CEXCEPTION_H_

#include <string>
#include <stdexcept>
#include <sstream>

#include "Type.h"
// #include "ArkBaseDefs.h"
#include "ArkCommonDefs.h"

#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable:4251)
#pragma warning(disable:4275)
#endif

namespace ArkCommon
{
	namespace Exception
	{
		//////////////////////////////////////////////////////////////////////////
		//class	KCExceptionInfo
		//////////////////////////////////////////////////////////////////////////

#if defined(_WIN32) && defined(__SGI_STL)
#pragma warning(push)
#pragma warning(disable:4275)
#endif

		class /*ARKCOMMON_API*/ CArkException
			:public std::exception
		{
		private:
			std::string		m_sWhat;
			std::string		m_sFile;
			std::string		m_sDate;
			std::string		m_sTime;
			std::string		m_sFunction;
			unsigned		m_uLine;

#ifndef _WIN32
			std::string		m_sBackTrace;
#endif
		public:
			CArkException(const std::string& sWhat,const std::string& sFile,
				const std::string& sDate,const std::string& sTime,
				unsigned uLine,const std::string& sFunction) throw();

			~CArkException() throw();

			const char* function()const throw();
			const char* date()const throw();
			const char* time()const throw();
			const char* file()const throw();
			const char* what()const throw();
#ifndef _WIN32
			const char* backtrace()const throw();
#endif
			unsigned line()const throw();
		};

#if defined(_WIN32) && defined(__SGI_STL)
#pragma warning(pop)
#endif

			//////////////////////////////////////////////////////////////////////////
			//macro	GenErr
			//////////////////////////////////////////////////////////////////////////

		void /*ARKCOMMON_API*/ _ArkGenerateError(const std::string& sMsg,const std::string& sFile
			,const std::string& sDate,const std::string& sTime,unsigned uLine,const std::string& sFunction);

#define	GenExp(ErrorMessage) \
		throw ArkCommon::Exception::CArkException(ErrorMessage,__FILE__,__DATE__,__TIME__,__LINE__,__FUNCTION__)

#define	GenErr(ErrorMessage) \
		{ArkCommon::Exception::_ArkGenerateError(ErrorMessage,__FILE__,__DATE__,__TIME__,__LINE__,__FUNCTION__);abort();}

#ifndef NDEBUG
#define	ArkAst(exp) \
	{if(!(exp))GenErr("Assertion failure of expresion '"#exp"'");}
#else
#define	ArkAst(exp)
#endif


#ifndef NDEBUG
#define	ArkVer(exp) \
	{if(!(exp))GenErr("Verification failure of expresion '"#exp"'");}
#else
#define	ArkVer(exp) (exp)
#endif


	}
}
using namespace	ArkCommon::Exception;

#ifdef _WIN32
#pragma warning (pop)
#endif

#endif //#ifndef _KCSSERT_H_

